#{extends 'mainStage.html' /}

#{set title:'Autoriser candidatures'  /}

    <div class="post">
        <h2 class="post-title">
			#{if listeCandidats.size != 0}
            	Liste des candidatures de ${listeCandidats.get(0).agent.cis} en attente autorisation
			
        </h2>
        <br>
			#{form @envoieAutorisation()}
			<table width="200" cellspacing='0' cellpadding='7' id="liste" class="display" summary="Liste des candidats" bgcolor="#E1EEF0">
				<thead>
					<tr>
						<th>Nom</th>
						<th>Pr&eacute;nom</th>
						<th>Statut</th>
						<th>Role</th>
						<th>Intitul&eacute; du stage</th>
						<th>Date de d&eacute;but</th>
						<th>Candidature partielle</th> 
					 	<th>Priorit&eacute;</th>
						<th>Autorisation</th>
						<th>Pr&eacute;cisions</th>
					</tr>
				</thead>
				<tbody>
				    #{list items:listeCandidats, as:'candid' }
    		       	<tr>
        		           	<td> <a href="@{candidats.detailCandid(candid.id)}">${candid.agent.nom}</a></td>
           		           	<td>${candid.agent.prenom}</td>
        				   	<td>${candid.agent.statut}</td>
							<td>${candid.role}</td>
							<td>
        	            		#{if candid.stage!=null}
        	            			<a href="@{Stages.detailStage(candid.stage.id)}">${candid.stage.intitule}</a>
        	            		#{/if}
        	            		#{else}
        	            			${candid.intitule}
        	            			(stage non planifi&eacute;)
        	            		#{/else}
        	            	</td>
        	            	<td>
        	            		#{if candid.stage!=null}
	        	            		#{if candid.stage.dateDeb!=null}
	        	            			${candid.stage.dateDeb.format('dd MMMM yyyy', 'fr')}
	        	            		#{/if}
	        	            		#{else}
	        	            			-
	        	            		#{/else}
	        	            	#{/if}		
    	            		</td>
        				   	<td>
        				   		#{if candid.candidPartielle}
        				   			#{if !candid.examenUv.isEmpty() }
        				   				#{list items:candid.examenUv, as:'uv'}
        				   					${uv}
        				   				#{/list}
        				   			#{/if}
        				   			#{else}
        				   				Candidat uniquement pour l'examen
        				   			#{/else}        				   	
        				   		#{/if}
        				   		#{else}
        				   			-
        				   		#{/else}
        				   	</td>
        				   	<td>
        				   		<select name="priorite${candid.id}" size="1" id="priorite${candid.id}" style="width:auto;">
                					<option value="0" selected="selected">-- Choisir une valeur --
        				   		#{list priorites, as:'priorite'}
					   				<option value="${priorite.id}">${priorite.ordre}</option> 
					   			#{/list}
				   				</select>
    				   		</td>
        				   	<td>
        				   	        Oui :<input type="radio" name="${candid.id}" id="O${candid.id}" value="oui" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false; testBox('${candid.id}')"><br/>
        				   	        Non :<input type="radio" name="${candid.id}" id="N${candid.id}" value="non" onmousedown="this.__chk = this.checked" onclick="if (this.__chk) this.checked = false; testBox('${candid.id}')">
        				   	</td>
        				    <td>
        				        <input type="text" class="precisions" id="motif${candid.id}" name="motif${candid.id}" disabled style="width: 50px;"/>
        				    </td>
    		       	</tr>
       			    #{/list} 
		       	</tbody> 
			</table>
			<br />
			<input type="submit" value="Valider changement" style="float:right;"/>
			<input type="hidden" value="${id}" name="id" />
		#{/form}
		#{/if}
		#{else}
			Aucune candidature en attente d'autorisation pour votre CIS ou service
		#{/else}
    </div>
	<script TYPE="text/javascript">
	function testBox(id){
		if(document.getElementById("N"+id).checked){
			document.getElementById("motif"+id).disabled=false;
		}
		else{
			document.getElementById("motif"+id).disabled=true;
			document.getElementById("motif"+id).value="";
		}
	}
	</script>